package com.lecture.java8.time;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 将日期转换成Date类型的数据
 * @author luyn
 * @date 2025/02/26
 */
public class DateConvert {

    public static void main(String[] args) throws ParseException {
        String dateString  = "20250216";
        String dateString2  = "20250215";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");

        Date parse = sdf.parse(dateString);

        DateTime parse1 = DateUtil.parse(dateString2);
        System.out.println(parse1);
        System.out.println(DateUtil.between(parse,parse1, DateUnit.DAY) == 1);

        System.out.println(parse);

    }
}
